import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 *Superclass that contains methods used by their subclasses.
 * 
 * @author Manuel Nava 
 * @version 1.0
 */
public class Enemy extends Actor
{
    private boolean isDeath;
    
    /**
     * The contructor set the boolean isDeath to false.
     */
    public Enemy()
    {
        isDeath=false;
    }
    
    /**
     * Getter that return the boolean isDeath().
     */
    public boolean getIsDeath()
    {
        return isDeath;
    }
    
    /**
     * Setter that changes the isDeath boolean variable.
     */
    public void setIsDeath(boolean d)
    {
        isDeath=d;
    }
    
    /**
     * The method act in this class is empty.
     */
    public void act() 
    {
        // Add your action code here.
    } 
    
    /**
     * The method death remove this object and the weapon class object that has touched it.
     */
    public void death()
    {
        if(isTouching(Weapon.class))
        {
            getWorld().removeObject(getOneIntersectingObject(Axe.class));
            getWorld().removeObject(this);
            isDeath=true;
        }
    }
     
    /**
     * The method move in this class moves the objects around the world with the scroll.
     */
    public void move()
    {
        if(((CaveWorld)(getWorld())).getCont()>0)
        {
        if(Greenfoot.isKeyDown("left")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()+5,getY());
        if(Greenfoot.isKeyDown("right")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()-5,getY());
        }
    }
}
